# Author:: Alexandre Ribeiro de Souza (<alexandre@lumis.com.br>)

include_recipe "logrotate"

logrotate_app "httpd" do
  cookbook "logrotate"
  path "/var/log/httpd/*log"
  frequency "daily"
  rotate 30
  create "644 root adm"
end

cron "logrotate" do
  hour "01"
  minute "00"
  command "/usr/sbin/logrotate /etc/logrotate.conf"
end

unless File.exists?("/mnt/backup")
  directory "/mnt/backup" do
    owner "root"
    group "root"
    mode "0755"
    recursive true
  end
end

template "/mnt/backup/monitor.rb" do
  source "monitor.rb.erb"
  mode "0755"
  owner "root"
  group "root"
  variables(
    :instance_id => node['ec2']['instance_id'],
    :node_name => Chef::Config[:node_name]
  )
end

cron "monitor" do
  hour "01"
  minute "30"
  command "/mnt/backup/monitor.rb"
end
